package com.woniuxy.kaer.service.config;

import org.springframework.amqp.core.Queue;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import java.util.HashMap;

@Configuration
public class RabbitMQConfig {
    @Bean
    public Queue waitingCheckPayQueue(){
        HashMap<String, Object> params = new HashMap<>();
        params.put("x-message-ttl", 2*60 * 1000);
        // x-dead-letter-exchange 属性用于声明死信转发到的交换机
        params.put("x-dead-letter-exchange", "d2");
        // x-dead-letter-routing-key 声明了这些死信在转发时携带的路由键名称。
        params.put("x-dead-letter-routing-key", "check_pay");
        return new Queue("waiting_check_pay_queue", true, false, false, params);
    }
    @Bean
    public Queue waitingCheckFinishQueue(){
        HashMap<String, Object> params = new HashMap<>();
        params.put("x-message-ttl", 10 * 1000);
        // x-dead-letter-exchange 属性用于声明死信转发到的交换机
        params.put("x-dead-letter-exchange", "d2");
        // x-dead-letter-routing-key 声明了这些死信在转发时携带的路由键名称。
        params.put("x-dead-letter-routing-key", "check_finish");
        return new Queue("waiting_check_finish_queue", true, false, false, params);
    }
    //用于超时没有上门的订单，，主要是实现异步
    @Bean
    public Queue deleteCacheQueue(){
        return new Queue("shop_points_calculated_queue");
    }

}
